package Game.Items.Others;

import org.newdawn.slick.SlickException;

import GUI.GuiManager;
import Game.Items.GameItem;
import Game.Objects.GameObject;

/** Map class
 * @author Aikidos
 */
public class GIMap extends GameItem {

	public GIMap() {
		super("Map");
		
		Category = ECategory.Other;
		
		_cost = 50;
		_weight = 0.09f;
	}

	@Override
	public boolean use() throws SlickException {
		if (_ownerGameObject.isPlayer()) {
			_ownerGameObject.getObjectManager().getLevel().getMap().openMap();

			GameObject[] trapdoors = _ownerGameObject.getObjectManager().getObjectsByClass("Game.Objects.GOTrapdoor");
			for (GameObject trapdoor : trapdoors) {
				GuiManager.getGuiMap().addMark(trapdoor.getCoord());
			}
			
			GameObject[] levers = _ownerGameObject.getObjectManager().getObjectsByClass("Game.Objects.GOLever");
			for (GameObject lever : levers) {
				GuiManager.getGuiMap().addMark(lever.getCoord());
			}
			
			// Show message
			GuiManager.getMessenger().addMessage(
					"[green]You[/green] used a [yellow]" + getName()
							+ "[/yellow]");

			return true;
		}
		
		return false;
	}
	
}
